﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data.Common;
using Data.Enum;
using DataAccess.FinancialManage;
using Microsoft.Reporting.WinForms;
using WinForm.Helper;
using WinForm.Reports;

namespace WinForm.FinancialManage
{
    public partial class PrintFinancialFrm : Form
    {
        public PrintFinancialFrm()
        {
            InitializeComponent();

            comboBoxEx1.SelectedIndex = 0;
        }

        private void labelX3_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;
            //判断是否登录
            //TODO:加权限判断
            if (SystemInfo.OperateName == null)
            {
                MyMessageBox.ShowMessageBoxInfo("对不起，您没有登录，没有打印权限！");
                return;
            }
            try
            {
                PrintFinBillFrm reportFrm = new PrintFinBillFrm("InOutFinRp.rdlc", dtpBegin.Value, dtpEnd.Value, SystemInfo.OperateAddressId);
                reportFrm.StartPosition = FormStartPosition.CenterScreen;
                reportFrm.ShowDialog();
            }
            catch (Exception e1)
            {
                errorMessage = errorMessage + e1.Message;
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                MyMessageBox.ShowMessageBoxInfo(errorMessage);
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                dtpBegin.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                DateTime d = DateTime.Now.AddDays(1);
                dtpEnd.Value = new DateTime(d.Year, d.Month, d.Day);
            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
            {
                dtpBegin.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                DateTime d = DateTime.Now.AddMonths(1);
                dtpEnd.Value = new DateTime(d.Year, d.Month, 1);
            }
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;
            //判断是否登录
            //TODO:加权限判断
            if (SystemInfo.OperateName == null)
            {
                MyMessageBox.ShowMessageBoxInfo("对不起，您没有登录，没有打印权限！");
                return;
            }
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor; //出现忙碌光标

                PrintFinBillFrm reportFrm = new PrintFinBillFrm("InOutFinRp.rdlc", dtpBegin.Value, dtpEnd.Value, SystemInfo.OperateAddressId);
                reportFrm.StartPosition = FormStartPosition.CenterScreen;
                reportFrm.ShowDialog();
            }
            catch (Exception e1)
            {
                errorMessage = errorMessage + e1.Message;
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                MyMessageBox.ShowMessageBoxInfo(errorMessage);
            }
        }
    }
}
